<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<meta name="renderer" content="webkit" />
		<meta http-equiv="Cache-Control" content="no-siteapp" />
		<meta name="App-Config" content="fullscreen=yes,useHistoryState=yes,transition=yes" />
		<meta content="yes" name="apple-mobile-web-app-capable" />
		<meta content="yes" name="apple-touch-fullscreen" />
		<meta content="telephone=no,email=no" name=format-detection />
		<meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
		<meta http-equiv="X-UA-Compatible" content="ie=edge">
		<title>提现</title>
	</head>
	<style>
		.txfs {
        width: 92%;
        margin-left: 4%;

    }

    .txfs p {
        overflow: auto;
        display: none;
        margin-top: 1rem;
    }

    .txfs p img {
        width: 1.5rem;
        float: left;

    }

    .txfs p span {
        color: #fff;
        font-size: 1rem;
        display: block;
        float: left;
        font-weight: bold;
        margin-left: 0.8rem;
    }

    .txfs p img:nth-of-type(2) {
        width: 1.5rem;
        float: right;
    }

    .txfs p span:nth-of-type(2) {
        float: right;
    }
</style>
	<link href="../c/withrawal.css" rel="stylesheet" />

	<body>
		<div class="txfs">
			<p class="weixin_has"><img id="wxjpg" src=""><span>微信</span><img id="wxsjpg" src=""></p>
			<p name="a" class="weixin"><img src="../i/addpic/wx.jpg"><span>您尚未设置微信账户</span><span onclick="_url({url:'member_band',title:'第三方绑定',pay:2});">立即绑定</span></p>
		</div>
		<p class="tite">提现金额</p>
		<input type="text" placeholder="单笔提现不超6000.00" class="inp je" />
		<p class="tite">收款人姓名</p>
		<input type="text" placeholder="微信绑定银行卡的实名" class="inp usen" />
		<button class="btnsua ljtx">立即提现</button>
		<button class="btnsua btnjl" onclick="_url({url:'details',title:'提现记录'})">提现记录</button>
	</body>

</html>
<script src="../j/api.js"></script>
<script src="../j/jquery-3.3.1.min.js"></script>
<script>
	function urlsa() {
		var imglen = $("img").length;
		var picurls = picurl + "/share";
		for (var i = 0; i < imglen; i++) {
			var tpl = $("img").eq(i).attr("src");
			// console.log(tpl)
			tpls = tpl.replace("../i/share", picurls);
			$("img").eq(i).attr("src", tpls);
		}
	}
	var bind_data = {}
	var xinming = ''
	var bind_id = ''
	var weixin = false
	apiready = function() {
		urlsa();
		var _user = _getPrefs('_user');
		_ajax('member/band_info', function(ret, err) {
			if (ret) {
				$(".txfs p").eq(0).show();
				weixin = true
				_ajax('member/tixian_money_list', function(ret, err) {
					if (ret) {
						bind_data = ret.band;
						if (bind_data.weixin) {
							xinming = bind_data.weixin.data.xingming
							bind_id = bind_data.weixin.id
							$(".usen").val(xinming)
						} else {}
					} else {
						// _alert(JSON.stringify(err));
					}
				})
			} else {
				$(".txfs p").eq(1).show();
			}
			_loadingCloes();
			_root = 1;
		})

		// 检测是否为中文
		function isChinese(temp) {
			var pattern = new RegExp("[\u4E00-\u9FA5]+");
			if (pattern.test(temp)) return true;
			return false;
		}
		// 绑定微信认证实名
		function bindRealName(text, pay) {
			_loading();
			_ajax('member/tixian_band_add', function(ret, err) {
				_loadingCloes();
				if (ret) {
					bind_id = ret.id;
				} else {
					_alert(JSON.stringify(err));
				}
			}, {
				xingming: text,
				pay: pay
			})
		}

		// 检测是否为数字
		function isNum(temp) {
			var pattern = new RegExp("^[1-9]\\d*$");
			if (pattern.test(temp) && temp >= 1 && temp <= 6000) return true;
			return false;
		}

		//发起提现
		$(".ljtx").on("click", function() {
			var name = $(".usen").val();
			var nm = $(this).text();
			if (nm != "立即提现") {
				_msg("请勿多次操作");
				return;
			} else {
				$(this).text("已提交请等待工作人员审核");
				if (!weixin) {
					return _msg("请先绑定微信！");
					window.location.href = "member_band.html";
				}
				if (xinming == '' || xinming != name) {
					bindRealName(name, 2)
				}
				var num = $(".je").val();
				var parls = num.split(".");
				var nums = num.replace(num.substring(num.indexOf("."), num.indexOf(".") + 3), "");
				if (num == "" || name == "") {
					$(this).text("立即提现")
					return _msg('请先完善取现金额和取现人姓名');
				} else if (!isChinese(name)) {
					$(this).text("立即提现")
					return _msg('请输入中文姓名');
				} else if (parls[1] == undefined) {
					$(this).text("立即提现")
					return _msg('提现金额不能为整数,带上任意两位小数！');
				} else if (parls[1].length > 2 || parls[1].length < 2 || parls[1] == 00 || parls[1] == "00") {
					$(this).text("立即提现")
					return _msg('提现金额不能为整数,带上任意两位小数！');
				} else if (!isNum(nums)) {
					$(this).text("立即提现");
					return _msg('提现金额为纯数字且不能超过6000.00！');
				} else {
					var ulr = "member/withdraw";
					_ajax(ulr, function(ret, err) {
						if (ret.ret != undefined && ret.ret != "undefined") {
							_alert(JSON.stringify(ret.ret));
							window.location.href = "details.html";
						} else {
							$(this).text("立即提现");
							return _msg(JSON.stringify(ret.err));
						}
					}, {
						money: num,
						name: name,
						band_id: bind_id,
						pay: 2
					})
				}
			}

		})
		// 回到屏幕
		api.addEventListener({
			name: 'viewappear'
		}, function(ret, err) {
			// alert("ss");
			$(".ljtx").text("立即提现")
		});
	}
</script>
